% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector Menu-Cost Model?" Review of Economics and Statistics
%
% Figure P + Table 4
clear;
tic


addpath('..\..\Utilities')  

load actual_moments_k
load res_estim_prod3l
param0=res_estim_prod3l

param0=   [param0(1) param0(4)  param0(7) ;
           param0(2) param0(5)  param0(8) ;
           param0(3) param0(6)  param0(9) ];% 



p0=abs(tanh(param0(:,1)));
mu_c=abs(param0(:,2));
sig_a=exp(param0(:,3));
rho_a=ones(3,1)*0.69;

param_m=[p0(1) mu_c(1) sig_a(1) rho_a(1)];
param_s=[p0(2) mu_c(2) sig_a(2) rho_a(2)];
param_e=[p0(3) mu_c(3) sig_a(3) rho_a(3)];

param_med2=[param_m' param_s'];
weight_sect2=[0.322; 0.188];

param_ms(1).param_ms=param_med2;
weight_ms(1).weight_ms=weight_sect2;


s=1;
%stat_mean3=ones(s,6);
for jj=1:s;
    
    param_med=param_ms(jj).param_ms;
    weight_sect=weight_ms(jj).weight_ms;
    p0=param_med(1,:);
    mu_c=param_med(2,:);
    sig_eps_a=param_med(3,:);
    rho_a=param_med(4,:);
    w=weight_sect'
    sm_m=0;
   [avmoments, moments, VC, IRF]=geNCalvoPlus_2Agg(sm_m, p0, mu_c, sig_eps_a, rho_a, w);

  stat_agg(jj,:)=[ avmoments sqrt(VC)]
  save stat_agg stat_agg;
  
    stat_sect(jj,:)=[ moments ]
  save stat_sect stat_sect;
  
   IRF_mean2he(jj,:)=[ IRF]
  save IRF_mean2he IRF_mean2he;
end
